<template>
  <!-- 显示状态 -->
  <div class="flex items-center flex-wrap">
    <div class="">{{ previewString.mainString || rowData.advName }}</div>
    <div class="text-gray-400 mx-1 text-xs">{{ previewString.subString }}</div>
    <a-tooltip v-if="rowData.advMemo && rowData.boxType !== '嘱托'" :title="rowData.advMemo">
      <RoundTag class="mx-1">嘱</RoundTag>
    </a-tooltip>
    <RoundTag v-if="rowData.drugPath" bg-color="#f50">备</RoundTag>
    <!-- <RoundTag bg-color="rgb(239 68 68)">皮</RoundTag> -->
  </div>
</template>

<script setup>
import { onMounted, ref } from 'vue'

const props = defineProps({
  rowData: {
    type: Object,
    default: () => ({})
  }
})
const previewString = ref({})
const getPreviewString = () => {
  let mainString = ''
  let subString = ''
  const transferZone = props.rowData.inpTransferZone || {} //转区
  const discharge = props.rowData.inpDischarge || {} //出院
  const { mc = '', gg = '' } = props.rowData.adv || {} //医嘱项目
  const {
    count = 0,
    countUnit = '',
    // clinicalDose,
    // clinicalDoseUnit,
    deliverRoute = { fyff: '' },
    fqy = { zjm: '' },
    fdayExecCount = 0,
    fdayExecTime = ''
  } = props.rowData
  const fdayExecCountStr = fdayExecCount ? `FD ${fdayExecCount}次` : ''
  const fdayExecTimeStr = fdayExecTime ? `FT ${fdayExecTime}` : ''
  switch (props.rowData.boxType) {
    case '嘱托':
      mainString = props.rowData.advName
      break
    case '转区':
      mainString = `患者拟于【 ${transferZone.transferDate} ${['AM', 'PM'][transferZone.ampm]}】
       转入【${transferZone.destDeptName}】【${transferZone.destWardName}】`
      break
    case '出院':
      mainString = `患者拟于【${discharge.dischargeDate} ${['AM', 'PM'][discharge.ampm]}】出院`
      break
    case '处置':
      mainString = `${mc} ${count}次` //药名+剂量+单位
      if (props.rowData.adv?.xmlb !== 7) {
        //护理类型不显示频率
        subString = `${fqy.plid} ${fdayExecCountStr} ${fdayExecTimeStr}`
      }
      break
    case '中草药':
      mainString = `${mc} ${count}${countUnit || ''}` //药名+剂量+单位
      subString = `${gg} ${deliverRoute.fyff} ${fqy.zjm} ${fdayExecCountStr} ${fdayExecTimeStr}` //规格+给药途径+频率+首次执行次数+首次执行时间
      break
    case '西成药':
      mainString = `${mc} ${count}${countUnit || ''}` //药名+剂量+单位
      subString = `${gg} ${deliverRoute.fyff} ${fqy.zjm} ${fdayExecCountStr} ${fdayExecTimeStr}` //规格+给药途径+频率+首次执行次数+首次执行时间
      break
  }
  previewString.value = { mainString, subString }
}
onMounted(() => {
  getPreviewString()
})
</script>
<style lang="less" scoped>
.dropdown-style {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  padding-right: 30px;
  padding-left: 8px;
  text-align: center;
}
:deep(.ant-dropdown-menu-item) {
  width: 66px;
  height: 60px;
  margin-right: 2px !important;
  .ant-dropdown-menu-title-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  &.ant-dropdown-menu-item-disabled {
    filter: opacity(0.5);
  }
}
.img-style {
  width: 20px;
  height: 20px;
  margin-bottom: 8px;
  img {
    width: 100%;
  }
}
</style>
